package com.ara.x.activity;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;

import com.ara.account.retrofit.AccountRouterApiHolder;
import com.ara.common.kernel.base.BaseActivity;
import com.ara.x.BuildConfig;
import com.ara.x.R;
import com.ara.x.databinding.ActivityLaunchBinding;
import com.ara.x.retrofit.MainRouterApiHolder;

/**
 * Created by XieXin on 2019/6/4.
 * 启动页
 */
public class LaunchActivity extends BaseActivity<ActivityLaunchBinding> {
    private final static int DELAY_MILLIS = 2 * 1000;//停留两秒
    private ConstraintLayout clContainer;

    @Override
    public void initView(@Nullable Bundle savedInstanceState) {
        clContainer = findViewById(R.id.clContainer);
        if (!BuildConfig.DEBUG) {//不是Debug启动停留两秒
            clContainer.postDelayed(this::isLogin, DELAY_MILLIS);
        } else {//是Debug直接启动
            isLogin();
        }
    }

    /**
     * 是否登录
     */
    private void isLogin() {
//        if (AccountUtils.isLogin()) {
        jumpMainActivity();
//        } else {
//            jumpLoginActivity();
//        }
    }


    /**
     * 跳转到主页
     */
    private void jumpMainActivity() {
        MainRouterApiHolder.jumpMainActivity();
        finish();
    }

    /**
     * 跳转到登录页面
     */
    private void jumpLoginActivity() {
        AccountRouterApiHolder.jumpLoginActivity(false);
        finish();
    }


    @Override
    public void onBackPressed() {
        //禁止返回按钮
    }
}
